<?php
/**
* 地图
* @author leiqianyong 2017-8-2 12:31 PM 
*/
class maps extends admin{
	private $table_maps = 'syt_maps'; //项目表
	
	private $table_mapstr='syt_mapstr'; //合并数据表

	
    //添加地图信息
    public function maps_add($data){
    	return $this->set_db($this->table_maps, $data);
    }	
    
    //添加地图合成数据信息
    public function mapstr_add($data){
    	return $this->set_db($this->table_mapstr, $data);
    }
	

    public function maps_list($pid=0){ 
    	return $this->maps_info($pid);
    	return;    	
    	
    	//数据路由设置 
        if($pid>=3194013){
        	return $this->maps_info($pid);
        	return;
        }
    	
    	$sql="select time,dis,coord_x,coord_y from {$this->table_maps} where pid={$pid} order by id asc";    	
    	$res=$this->_mysql(0)->find($sql);
    	return $res;
    }
    
    
    public function maps_info($pid=0){
    	$sql="select coord,dis from {$this->table_mapstr} where pid={$pid} order by id desc";       	
    	$res=$this->_mysql(0)->findone($sql);    	    	    	
    	if(empty($res) || empty($res['coord']))return false;    	
    	$list=$this->string2array($res['coord']);
    	return $list;    	
    }
    
    
    /**
     * 字符串到数组
     * @param unknown $data
     * @return multitype:|unknown
     */
    function string2array($data) {
    	if($data == '') return array();
    	@eval("\$array = $data;");
    	return $array;
    }    
    
   	
}
?>